<template>
    <div ref="main" style="width: 100%;height: 100%;"></div>
</template>

<script setup lang="ts">
import * as echarts from 'echarts';
import {ref,onMounted,defineProps,onUnmounted} from 'vue';
const option = defineProps(['option']);
const main = ref(null);
let remove:any=null
onMounted(async()=>{
var myChart = echarts.init(main.value);

function add(){
    // 内存泄露
    myChart.resize();
}
remove =add
window.addEventListener("resize",add)
myChart.setOption(option.option)
});

onUnmounted(()=>{
    window.removeEventListener("resize",remove)
})

</script>

<style scoped>
#main{
    width: 100%;
    height: 100%;
}
</style>
